package com.frank.loadinglibrary.special.dot.circle;


import ohos.agp.render.Canvas;
import ohos.agp.render.Paint;
import ohos.agp.utils.RectFloat;

/**
 * @author SUQI
 * @date 2021/5/27
 * @description
 **/
public class BeadCircle extends BaseCircle {
    private float mOriginR;
    private RectFloat rectF;
    private boolean isCircle = true;

    public BeadCircle(float x, float y, float r) {
        super(x, y, r);
        mOriginR = r;
        rectF = new RectFloat(x - radius, y - radius, x + radius, y + radius);
    }

    @Override
    public void draw(Canvas canvas, Paint paint) {
        if (isCircle) {
            canvas.drawCircle(x, y, radius, paint);
        } else {
            canvas.drawOval(rectF, paint);
        }
    }

    @Override
    public void bigger(float level) {
        radius = mOriginR + level;
    }

    public void drop(float y) {
        this.y = y;
    }

    public void flatten(float r) {
        if (isCircle) {
            isCircle = false;
        }
        rectF.left = x - radius;
        rectF.top = y -r;
        rectF.right = x + radius;
        rectF.bottom = y + radius;
    }

    /**
     * 恢复原状
     */
    public void reset(float x, float y) {
        radius = mOriginR;
        this.x = x;
        this.y = y;
        isCircle = true;
    }
}
